﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.admin.shop
{
    public partial class shop_affiche_edit : System.Web.UI.Page
    {
        YXShop.BLL.Shop.Shop shopBll = new YXShop.BLL.Shop.Shop();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                YXShop.Common.PromptInfo.Popedom("013005004", "对不起，您没有权限进行编辑");
                InitWebControl();
                string shopId = ChangeHope.WebPage.PageRequest.GetQueryString("shopId");
                if(shopId!=null&&shopId!="")
                {
                    ViewState["shopId"] = shopId;
                    YXShop.Model.Shop.Shop shop = shopBll.GetModelById(Convert.ToInt32(shopId));
                    if(shop!=null)
                    {
                        this.lblNumber.Text = shop.Shopnum.ToString();
                        this.lblName.Text = shop.Shopname.ToString();
                        this.txtAffiche.Text = shop.Affiche.ToString();
                    }
                }
            }
        }

        private void InitWebControl()
        {
            ChangeHope.WebPage.WebControl.Validate(this.txtAffiche,"请输入店铺公告","isnull","必填","该项为必填项");
            this.Form.Attributes.Add("onsubmit","return CheckForm()");
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if(ViewState["shopId"]!=null)
            {
                YXShop.Model.Shop.Shop model = shopBll.GetModelById(Convert.ToInt32(ViewState["shopId"]));
                model.Affiche = this.txtAffiche.Text.Trim().ToString();
                int count = shopBll.Update(model);
                if (count > 0)
                {
                    this.ltlMsg.Text = "操作成功，已经修改信息";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                }
                else
                {
                    this.ltlMsg.Text = "操作失败";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionErr";
                }
            }
            
        }
    }
}
